package com.onpositive.mediawiki.dataminer;

import java.io.File;

import com.onpositive.dataminer.core.DataProviderConfig;
import com.onpositive.dataminer.core.IDataProvider;
import com.onpositive.knowledge.model.IThing;
import com.onpositive.knowledge.model.IUniverse;

public class MediaWikiDataProvider implements IDataProvider {

	private DataProviderConfig config;

	public MediaWikiDataProvider(DataProviderConfig config) {
		this.config=config;
	}

	@Override
	public DataProviderConfig getConfig() {
		return config;
	}

	@Override
	public void onUninstall() {

	}

	@Override
	public void onInstall() {

	}
	MediaWikiUniverse universe;

	@Override
	public IUniverse getUniverse() {
		if (universe==null){
			File providerTypeDataArea = config.getProviderTypeDataArea();
			providerTypeDataArea.mkdirs();
			String absolutePath = providerTypeDataArea.getAbsolutePath();
			universe=new MediaWikiUniverse(absolutePath+"//storage",config.getUrl());
			universe.extractCategory(config.getUrl());
			
		}
		return universe;
	}
	@Override
	public String toString() {
		return config.getUrl();
	}


}
